package leetcode.code1362;

public class Solution {

	public int[] closestDivisors(int num) {
		int[] ans1 = this.f(num + 1);
		int[] ans2 = this.f(num + 2);
		return Math.abs(ans1[0] - ans1[1]) < Math.abs(ans2[0] - ans2[1]) ? ans1 : ans2;
	}

	public int[] f(int num) {
		int m = (int) Math.sqrt(num);
		if (m * m == num) {
			return new int[] { m, m };
		}
		for (int i = m; i >= 0; i--) {
			if ((num % i) == 0) {
				return new int[] { i, num / i };
			}
		}
		return null;
	}

}
